package com.lytoyo.neihanduanzi.config;

import com.qcloud.cos.COSClient;
import com.qcloud.cos.ClientConfig;
import com.qcloud.cos.auth.BasicCOSCredentials;
import com.qcloud.cos.auth.COSCredentials;
import com.qcloud.cos.region.Region;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Package:com.lytoyo.neihanduanzi.config
 *
 * @ClassName:CosClientConfig
 * @Create:2025/4/3 17:49
 **/
@Configuration
@ConfigurationProperties(prefix = "cos")
@Data
public class CosClientConfig {
    private String accessKey;

    private String secretKey;

    private String region;

    private String bucket;

    private String baseUrl;

    @Bean
    public COSClient COSClient (){

        COSCredentials cred = new BasicCOSCredentials(accessKey, secretKey);
        Region region = new Region(this.region);
        ClientConfig config = new ClientConfig(region);
        return new COSClient(cred, config);
    }
}
